import React, { useState } from 'react'
import randomcolor from 'randomcolor';

export default function ChangeBg() {
  // 声明状态
  let [bg, setBg] = useState('rgb(40, 20, 200)');
  //声明事件回调 changeBg
  let changeBg = () => {
    //更新状态
    setBg(randomcolor());
  }
  return (
    <div onClick={changeBg} style={{width: 400, height: 300, background: bg}}>
    </div>
  )
}
